package com.xiaobai.zhuangxiuguanjia.activities;

import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.xiaobai.zhuangxiuguanjia.R;
import com.xiaobai.zhuangxiuguanjia.Utils.PhoneCall;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;

public class MyToolBoxActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_toolbox);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle("工具箱");
        actionBar.setDisplayHomeAsUpEnabled(true);

        Button zxb = (Button) findViewById(R.id.toolbox_zxb);
        Button zxlc = (Button) findViewById(R.id.toolbox_zxlc);
        Button zxzx = (Button) findViewById(R.id.toolbox_zxzx);
        zxb.setOnClickListener(this);
        zxlc.setOnClickListener(this);
        zxzx.setOnClickListener(this);
    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.toolbox_zxb:
                startActivity(new Intent(this, ZxbActivity.class));
                break;
            case R.id.toolbox_zxlc:
                // TODO 检查是否已经登陆
                Platform qq = ShareSDK.getPlatform(QQ.NAME);
                Platform sina = ShareSDK.getPlatform(SinaWeibo.NAME);
                if (!qq.isValid() && !sina.isValid())
                    startActivity(new Intent(this, LoginActivity.class));
                break;
            case R.id.toolbox_zxzx:
                PhoneCall.phoneCall(this);
                break;
        }
    }
}
